package client.comm.baoding.adapter

import androidx.recyclerview.widget.DiffUtil
import client.comm.baoding.R
import client.comm.baoding.api.bean.SignData
import client.comm.baoding.databinding.LayoutItemSgGuadBinding
import client.comm.baoding.databinding.LayoutItemSignBinding
import client.comm.commlib.base.BasePagingAdapter
import client.comm.commlib.base.PagingViewHoder
import com.google.gson.Gson

class SignAdapter() : BasePagingAdapter<SignData.Order>(object :

    DiffUtil.ItemCallback<SignData.Order>() {
    val gson = Gson()
    override fun areItemsTheSame(
        oldItem: SignData.Order,
        newItem: SignData.Order
    ): Boolean {
        return true
    }

    override fun areContentsTheSame(
        oldItem: SignData.Order,
        newItem: SignData.Order
    ): Boolean {
        return gson.toJson(oldItem).equals(gson.toJson(newItem))
    }
}) {

    override fun bindItem(holder: PagingViewHoder, t: Any) {
        val binding = holder.binding as LayoutItemSignBinding
        val bean = t as SignData.Order
        binding.bean = bean

    }

    override fun getItemLayout(): Int {
        return R.layout.layout_item_sign
    }

}